<?php

class Comment_Table_Model_Comment extends Database_Table_Row
{
	/**
	 * @var string
	 */
	protected $_pk = 'comment_id';

	/**
	 * @var string
	 */
	protected $_itemType = 'activity/comment';

	/**
	 * @return string
	 */
	function getId()
	{
		return $this -> comment_id;
	}

	/**
	 *  get like message
	 */
	function getLikeMessage()
	{
		$count = $this -> like_count;

		$result = $this -> isLiked;

		if ($result)
		{
			$count -= 1;
		}

		return Intl::__('<a href="#" class="uiCommentLikeLink" hover="tooltip" aria-click="fbox" title="You and me like this" hover-url=":url" >:like_count</a>', array(':like_count' => $this -> like_count));
	}

	/**
	 * when object is deleted please delete associate like/comment/favourite & other etc by object_type and object_id
	 */
	protected function _delete()
	{
		/**
		 * call parent delete by default.
		 */
		parent::_delete();

		$obj = $this -> getObject();
		if ($obj && isset($obj -> comment_count))
		{
			$obj -> comment_count -= 1;
			$obj -> save();
		}
	}
}
